package com.qianyu.project.mapper.provider.smj;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;

import java.util.Map;

public class smjRealnameProvider {
    //获取劳务实名制列表
    public  String ListFragmentary(IPage<Map<String, Object>> page, Map<String, String> params){
        return new SQL(){
            {
                SELECT(" r.*,p.*,pi.project_name");
                FROM("realname r ");
                LEFT_OUTER_JOIN("profession p on r.profession=p.id");
                LEFT_OUTER_JOIN("project_info pi on r.p_id=pi.id ");
                if (!ObjectUtils.isEmpty(params.get("id"))){
                    WHERE("r.id ='"+params.get("id")+"'");
                }
                if (!ObjectUtils.isEmpty(params.get("name"))){
                    WHERE("r.name ='"+params.get("name")+"'");
                }
                if (!ObjectUtils.isEmpty(params.get("sfz"))){
                    WHERE("r.sfz ='"+params.get("sfz")+"'");
                }
                if (!ObjectUtils.isEmpty(params.get("profession"))){
                    WHERE("r.profession ='"+params.get("profession")+"'");
                }
                if (!ObjectUtils.isEmpty(params.get("projectId"))){
                    WHERE("r.p_id ='"+params.get("projectId")+"'");
                }
                if (!ObjectUtils.isEmpty(params.get("start_date"))){
                    WHERE("r.apply_date >='"+params.get("start_date")+"'");
                }
                if (!ObjectUtils.isEmpty(params.get("end_date"))){
                    WHERE("r.apply_date <='"+params.get("end_date")+"'");
                }
            }
        }.toString();
    }
}
